﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;


namespace YKXiangQi.Controls
{
    /// <summary>
    /// Interaction logic for XiangqiTimer.xaml
    /// </summary>
    public partial class TimerControl : UserControl
    {
        public TimerControl()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty CloseCommandProperty =
            DependencyProperty.Register("CloseCommand", typeof(ICommand), typeof(TimerControl),
                                        new PropertyMetadata(default(ICommand)));

        public static readonly DependencyProperty CloseCommandParameterProperty =
            DependencyProperty.Register("CloseCommandParameter", typeof (object), typeof (TimerControl), new PropertyMetadata(default(object)));

        public object CloseCommandParameter
        {
            get { return GetValue(CloseCommandParameterProperty); }
            set { SetValue(CloseCommandParameterProperty, value); }
        }

        public ICommand CloseCommand
        {
            get
            {
                return (ICommand)GetValue(CloseCommandProperty);
            }
            set
            {
                SetValue(CloseCommandProperty, value);
            }
        }

        private void OnClose(object sender, MouseButtonEventArgs e)
        {
            if (CloseCommand != null)
                CloseCommand.Execute(CloseCommandParameter);
        }

    }
}
